package top.yonyong.mynacos.configcenter.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yonyong.mynacos.configcenter.container.MyConfigContainer;
import top.yonyong.mynacos.configcenter.dao.ConfigRepository;
import top.yonyong.mynacos.configcenter.pojo.ConfigInfo;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Describtion Todo
 * @Author yonyong
 * @Date 2020/7/6 11:00
 * @Version 1.0.0
 **/
@RestController
@RequestMapping("/monitor/")
public class MonitorController {

    @Resource
    private MyConfigContainer myConfigContainer;

    @Resource
    private ConfigRepository configRepository;

    @GetMapping("vals/sys")
    public Object getSysConfig(){
        final List<ConfigInfo> vals = myConfigContainer.getVals();
        return vals;
    }

    @GetMapping("vals/db")
    public Object getFbConfig(){
        final List<ConfigInfo> aDefault = configRepository.queryAllByGroupOrderByUpdateTime("DEFAULT");
        return aDefault;
    }
}
